# -*- coding: utf-8 -*-
from 考试系统.数据处理层 import check
#import check
from 考试系统.数据处理层 import stu1
from 考试系统.数据处理层 import activate
from 考试系统.数据处理层 import yzm
from 考试系统.数据处理层 import Class
from 考试系统.数据处理层 import topic
from 考试系统.数据处理层 import tj
from 考试系统.数据处理层 import teacher

global_var = 0


# -*- coding: utf-8 -*-
# def check_node(node):#检查代码是否报错
#     check.code_check(node)
# 检查代码
def use_number_is_in(number, id):  # 检测该手机号是否已经注册
    return check.number_in_check(number, id)


def id_is_in(id):  # 检查该学号是否已经注册
    return check.id_check(id)


def use_in(id, number, password, name):  # 注册
    return check.ues_in(id, number, password, name)


def ues_activate_number_or_name_and_password(shu, password):  # 使用(手机号或者账号)加密码进行登录
    un = activate.number_or_name_and_password(shu, password)
    global global_var
    global_var = shu
    return activate.number_or_name_and_password(shu, password)


def ues_number_and_yzm(number):  # 手机号和验证码登录
    s = check.number_check(number)
    if s:
        return True
    global global_var
    global_var = activate.num_find_id(number)


def yzm_out(number):  # 输入手机号，返回验证码
    return yzm.yzm(number)


def use_number_find_password(number):  # 通过手机号验证得到密码
    return activate.number_find_password(number)


def create_class(name):  # 老师创建班级
    teacher.crete_class(global_var, name)


def teacher_is_create_class(class_name):  # 检查老师是否创建该班级
    check.class_teacher_check(global_var, class_name)


def stu_all_show():  # 返回所有学生信息
    return stu1.stu_all_show()


def class_input_stu(stus, class_name):  # 添加学生到班级里面
    return Class.class_add_stu(stus, class_name)


def class_input_paper(paper, class_name):  # 添加试卷到班级里面
    Class.class_add_paper(paper, class_name)


def stu_find_class_paper():  # 学生查看自己的班级
    return Class.stu_find_class_paper(global_var)


def class_name_find_paper(class_name):  # 返回班级试卷的名字
    return Class.class_name_find_paper(class_name)


def paper_name_out_topics(paper_name):  # 通过试卷名字返回题目
    return topic.paper_name_find_topics(paper_name)


def stu_find_paper_topics(topics):  # 学生查看试卷
    return topic.by_paper_Topic(topics)


def stu_find_topics(id):  # 通过题号返回题目
    return topic.topic_out(id)


def teacher_class_show():  # 返回这个老师开的课程
    return teacher.teacher_class_show(global_var)


def Topic_add(id, text, name, text_small):  # 出题，将题目添加到题库中
    return topic.Topic_add(id, text, name, text_small)


def Topic_check(id):  # 检测该题目是否已经在题库中了
    return check.check_Topic(id)


def Topic_show():  # 展示所有题目
    return topic.Topic_show()


def paper_name_chock(name):  # 检测试卷名字是否合规
    return check.check_paper_name(name)


def paper_name_is_in(name):  # 检测要创建试卷的名字是否已经存在
    return check.check_paper_is_in(name)


def paper_creat(name, Topics):  # 创建试卷
    return topic.paper_creat(name, Topics)


def paper_show():  # 返回全部试卷
    return topic.paper_show()


def out_topic(id):  # 通过id返回题目所有信息
    topic1 = topic.topic_out(id)
    return topic1


def zuoda(text, id, ):  # 学生提交代码，判断是否正确+
    stuid = global_var
    topic1 = topic.topic_out(id)
    topic_yangli_and_daan = topic[5]
    image = tj.oo(text, topic_yangli_and_daan)
    if image[0] == True:
        stu1.stu_chengji_gai(global_var)
        return image
    else:
        return image


def chengji():  # 学生查看成绩
    stu1.stu_chengji_gai(global_var)
